package com.wuxiaofan.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.entity.Patient;
import com.wuxiaofan.entity.custom.PatientCustom;
import com.wuxiaofan.mapper.PatientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.config.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class PatientService {
    @Autowired
    private PatientMapper patientMapper;
    @Resource
    private Idgenerator idgenerator;
    public Patient findById(String id){
        return patientMapper.selectById(id);
    }

    public PatientCustom findCountByMap(Map paraMap){
        return patientMapper.findCountByMap(paraMap);
    }

    public PatientCustom findGroupByMap(Map paraMap){
        return patientMapper.findGroupByMap(paraMap);
    }

    public List<PatientCustom> findByMap(Map paraMap){
        return patientMapper.findByMap(paraMap);
    }

    public Page<PatientCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(patientMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        patientMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        patientMapper.deleteById(id);
    }

    public Patient save(Patient patient){
        patient.setId(idgenerator.getId());
        patientMapper.insert(patient);
        return patient;
    }

}
